<%--
 *  File:    AccountingYearSummary.jsp
 *  @Author: Langerwang 
 *  Date:    2002/1/25
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.AccountingYearSummary");  
  String privilegeCode = "40106";
  String strTableName = "ovbooksetaccountingyear";
  String strModuleName = "SPM";
%>



<%
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");
  Integer nCurOrgId = (Integer)userInfo.get("orgid");
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>AccountingYearSummary</title>
<PageFlow:CheckPageFlow pageName="accountingyearsummary"/>
<%@ include file="/inc/SummaryDivision.inc" %>

<%
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);  
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);  
  cat.debug("The nCurCount is :" + nCurCount);  
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);          
  cat.debug("The nCurRowCount is :" + nCurRowCount);          

  Vector accountingYearSummary = (Vector)pageContext.getAttribute("accountingyearsummary");
  if(accountingYearSummary == null)
  {
    accountingYearSummary = new Vector();
  }
  cat.debug("The accountingYearSummary is :" + accountingYearSummary);
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>

<script>
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function clickAccYear(id,status,ownerorgid)
{
  parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
  document.accountingyearsummaryform.accyearid.value = id;
  document.accountingyearsummaryform.accyearstatus.value = status;
  document.accountingyearsummaryform.ownerorgid.value = ownerorgid;
}
function page_createnewyear()
{
   
    document.accountingyearsummaryform.actionname.value = "create";
    document.accountingyearsummaryform.target = "_parent"; 
    isRunning = true; 
    document.accountingyearsummaryform.submit();
}
function page_deletelastyear()
{
    var id = document.accountingyearsummaryform.accyearid.value;
    if(id == "-1")
        return;

    var flag = confirm('<%=message.getMessageDesc("ARE_YOU_SURE_DEL")%>');
    if(!flag)
        return;
    
    document.accountingyearsummaryform.actionname.value = "delete";
    document.accountingyearsummaryform.target = "_parent"; 
    isRunning = true; 
    document.accountingyearsummaryform.submit();
}
function page_edit()
{
  var id = document.accountingyearsummaryform.accyearid.value;
  if(id == "-1")
    return;
   <%--[SCRIPT]         if(document.accountingyearsummaryform.accyearstatus.value < "<#%= ConstantProp.USED_STATUS %#>")   [SCRIPT]--%>
   <%--[SCRIPT]         {  [SCRIPT]--%>
   <%--[SCRIPT]           alert("<#%= message.getMessageDesc("NOT_YET_ACTIVE",label.getLabelName("L_AccountingYear",false)) %#>");   [SCRIPT]--%>
   <%--[SCRIPT]           return;  [SCRIPT]--%>
   <%--[SCRIPT]         }  [SCRIPT]--%>
  if(document.accountingyearsummaryform.accyearstatus.value==99) 
  {
        alert("<%= message.getMessageDesc("CAN_NOT_EDIT_IT") %>"); 
        return;
  } 
  if( document.accountingyearsummaryform.ownerorgid.value != "<%=JspHelper.filterNull( nCurOrgId )%>")
  {
    alert("<%= message.getMessageDesc("NO_RIGHT") %>"); 
    return;
  }  
  var strStatus=document.accountingyearsummaryform.accyearstatus.value;
  var editurl = "AccountingPeriodEdit.jsp?<%= OvalTools.randomURL() %>&accyearid=" + id + "&languagecode=" + "<%= strLanguageCode %>&accyearstatus="+strStatus;  
  parent.down.location.href = editurl;
}
function page_start()
{
  var id = document.accountingyearsummaryform.accyearid.value;
  if(id == "-1")
    return;
  var status = document.accountingyearsummaryform.accyearstatus.value;
  if(document.accountingyearsummaryform.ownerorgid.value != "<%=JspHelper.filterNull( nCurOrgId )%>")
  {
    alert("<%= message.getMessageDesc("NO_RIGHT") %>"); 
    return;
  }
  if(status == "<%= ConstantProp.CLOSE_STATUS %>")
  {
    alert("<%= message.getMessageDesc("ALREADY_CLOSED",label.getLabelName("L_AccountingYear",false)) %>"); 
    return;
  }
  if(status >= "<%= ConstantProp.USED_STATUS %>")
  {
    alert("<%= message.getMessageDesc("ALREADY_ACTIVED",label.getLabelName("L_AccountingYear",false)) %>"); 
    return;
  }

  if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_ACTIVE",label.getLabelName("L_AccountingYear",false)) %>"))
  {
    return;
  }
  document.accountingyearsummaryform.actionname.value = "active";
  document.accountingyearsummaryform.target = "_parent";  
  isRunning = true;
  document.accountingyearsummaryform.submit();
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(accountingyearsummaryform,actionvalue,orderbyname);
  editform.action = "AccountingYearSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function page_view()
{
  var id = document.accountingyearsummaryform.accyearid.value;
  var editurl = "AccountingPeriodInfo.jsp?<%= OvalTools.randomURL() %>&accyearid=" + id + "&languagecode=" + "<%= strLanguageCode %>";  
  parent.down.location.href = editurl;
}


</script>
</head>
<body>
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <form name="accountingyearsummaryform" method="post" action="../../Dispatcher">
      <input type="hidden" name="pagename" value="accountingyearsummary">
      <input type="hidden" name="actionname">   
          
        <input type="hidden" name="rowcount" value="<%=JspHelper.filterNull( nCurRowCount )%>">           
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">

        <tr class="deepblue-left"> 
          <td width="22" class="title_center">&nbsp;</td>
          <td class="title_center"><a href="javascript:page_summary('orderby','accyear')"><%= label.getLabelName("L_AccountingYear") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','currencyname')"><%= label.getLabelName("L_HomeCurrency") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','accperiodnum')"><%= label.getLabelName("L_NoOfAP") %></a></td>
          <td class="title_center" width="80"><a href="javascript:page_summary('orderby','begindate')"><%= label.getLabelName("L_BeginningMonth") %></a></td>
          <td class="title_center" width="80"><a href="javascript:page_summary('orderby','enddate')"><%= label.getLabelName("L_EndingMonth") %></a></td>
          <td class="title_center" width="40"><a href="javascript:page_summary('orderby','accyearstatus')"><%= label.getLabelName("L_Status") %></a></td>
        </tr>                
        
          <%
             int i = 0;
             String strClassType = new String();   
             String strIsChecked = "Checked";
             Integer nDefaultAccYearId = new Integer(-1); 
             Integer nAccYearStatus = new Integer(-1); 
             Integer nDefaultOwnerOrgId = new Integer(-1); 
          %>
          <logic:iterate id="acc" collection="<%= accountingYearSummary %>">                      
          <%
            HashMap accMap = (HashMap)pageContext.getAttribute("acc"); 
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(i != 0)
            {          
              strIsChecked = "";
            }  
            else
            {
              strIsChecked = "Checked";
              nDefaultAccYearId = (Integer)(accMap.get("accyearid"));
              nAccYearStatus = (Integer)(accMap.get("accyearstatus"));
              nDefaultOwnerOrgId = (Integer)(accMap.get("ownerorgid"));
            } 
            i++;     
           %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue('acc<%=JspHelper.filterNull( i )%>');clickAccYear('<%=JspHelper.filterNull( accMap.get("accyearid") )%>','<%=JspHelper.filterNull( accMap.get("accyearstatus") )%>','<%=JspHelper.filterNull( accMap.get("ownerorgid") )%>');" class="<%=JspHelper.filterNull( strClassType )%>"> 
            <td>
              <input type="radio" id="acc<%=JspHelper.filterNull( i )%>" name="checkhehe" value="<%=JspHelper.filterNull( accMap.get("accyearid") )%>" class="normalradio" <%=JspHelper.filterNull( strIsChecked)%>>
            </td>
            <td>&nbsp;<% if(((Integer)accMap.get("accyearstatus")).intValue() != ConstantProp.INACTIVE_STATUS){%><a href="javascript:page_view()"><%=JspHelper.filterNull( accMap.get("accyear") )%></a><%}else{%><%=JspHelper.filterNull( accMap.get("accyear") )%><%}%></td>
            <td>&nbsp;<%=JspHelper.filterNull( accMap.get("currencyname") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( accMap.get("accperiodnum") )%></td>
            <td>&nbsp;<%= OvalTools.dateToString(accMap.get("begindate"),(String)session.getAttribute("dateformat")) %></td>
            <td>&nbsp;<%= OvalTools.dateToString(accMap.get("enddate"),(String)session.getAttribute("dateformat")) %></td>
            <td>&nbsp;<%=JspHelper.filterNull( accMap.get("accyearstatusname") )%></td>
          </tr>
          </logic:iterate>                   
          <input type="hidden" name="accyearid" value="<%=JspHelper.filterNull( nDefaultAccYearId )%>">  
          <input type="hidden" name="accyearstatus" value="<%=JspHelper.filterNull( nAccYearStatus )%>">  
          <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">  
          <input type="hidden" name="ownerorgid" value="<%=JspHelper.filterNull( nDefaultOwnerOrgId )%>">  
        <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
              <a onclick="page_createnewyear()"><custom:button type="1" label="L_Createnewyear" imgsrc="createnewyear.gif" border="0"/></a>
              <%if(accountingYearSummary.size()>0){%>
              <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
              <a onclick="page_start()"><custom:button type="1" label="L_Startup" imgsrc="Startup.gif" border="0" style="width:60"/></a>
              <a onclick="page_deletelastyear()"><custom:button type="1" label="L_Deletelastyear" imgsrc="deletelastyear.gif" border="0"/></a>
              <%}%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
        </form>  
</table>
</body>
</html>


